package cn.edu.guet.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
@Configuration
// web配置文件（web.xml）添加一个拦截器
public class SessionConfiguration implements WebMvcConfigurer {
    @Override
    public void addInterceptors(InterceptorRegistry registry ){
        registry.addInterceptor(new SessionInterceptor()).addPathPatterns("/**")
                .excludePathPatterns("/css/**","/js/**","/img/**","/font/**","/images/**","/lay/**","/favicon.ico","/layui.all.js","/layui.js")//排除样式、脚本、图片等资源文件
                .excludePathPatterns("/iframe")//排除home页面
                .excludePathPatterns("/login")//排除登录操作
                .excludePathPatterns("/login.do")//排除登录操作
                .excludePathPatterns("/iframe222")//排除页面
                .excludePathPatterns("/viewPost")
                .excludePathPatterns("/viewLastestPost")
                .excludePathPatterns("/viewHottestPost")
                .excludePathPatterns("/viewDgroup")
                .excludePathPatterns("/viewPType")
                .excludePathPatterns("/errorPage/*")
                .excludePathPatterns("/authCode.do")
                .excludePathPatterns("/html/login/index")
                .excludePathPatterns("/forget1.do")
                .excludePathPatterns("/mail.do")
                .excludePathPatterns("/getuser.do")
                .excludePathPatterns("/sendMail.do")
                .excludePathPatterns("/checkMail.do")
                .excludePathPatterns("/usermail.do")
                .excludePathPatterns("/change.do")
                .excludePathPatterns("/mailLog.do")
                .excludePathPatterns("/selectMajor.do")
                .excludePathPatterns("/decide.do")
                .excludePathPatterns("/success.do")
                .excludePathPatterns("/check.do")
                .excludePathPatterns("/viewNumOfPostMap")
                .excludePathPatterns("/main");//排除主页
        //网站配置生成器：添加一个拦截器，拦截路径为整个项目
    }
}